﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace XDQ.VAT.Lockers
{
    public interface IDistributeLocker
    {
        /// <summary>
        /// 尝试锁
        /// </summary>
        /// <typeparam name="TMainEntity"></typeparam>
        /// <returns></returns>
        Task<bool> TryLock<TMainEntity>();

        /// <summary>
        /// 尝试锁
        /// </summary>
        /// <typeparam name="TMainEntity"></typeparam>
        /// <returns></returns>
        Task<bool> TryLock<TMainEntity>(TimeSpan wait);

        /// <summary>
        /// 释放锁
        /// </summary>
        /// <typeparam name="TMainEntity"></typeparam>
        /// <returns></returns>
        Task<bool> Release<TMainEntity>();
    }


}
